package com.ganbo.ms.socket;

import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;


public class SocketClient {

    public static void main(String[] args) throws IOException, InterruptedException {
        int i = 0;

        while (true) {
            Socket socket = new Socket(InetAddress.getLocalHost(), 9988);
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));

            bw.write("hello 我是客户端11111111111111==============>" + (++i));
            bw.newLine();
            bw.flush();

            BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            System.out.println("============");
            System.out.println(br.readLine());
            System.out.println("===========");

            br.close();
            bw.close();
            socket.close();

            Thread.sleep(1000);
        }
//        System.out.println("客户端执行完毕");
    }
}
